/***
 * * PROJECT
 * *    ATaG
 * * VERSION
 * *    $Revision: 1.1 $
 * * DATE
 * *    $Date: 2006/11/03 23:08:14 $
 * * LOG
 * *    $Log: RampSampler.java,v $
 * *    Revision 1.1  2006/11/03 23:08:14  lmottola
 * *    Traffic application beta running.
 * *
 * *    Revision 1.1  2006/10/27 01:30:55  animesh
 * *    trafficapplication renamed to atag.trafficapplication
 * *
 * *    Revision 1.1  2006/10/27 01:28:06  animesh
 * *    Traffic Application Added.
 * *
 * *    Revision 1.2  2006/10/19 21:21:53  lmottola
 * *    Added CVS preamble.
 * *
 * *
 * *   ATaG (Abstract Task Graph) - Data-driven Macroprogramming for
 * *                                Sensor Networks
 * *
 * *   This program is free software; you can redistribute it and/or
 * *   modify it under the terms of the GNU General Public License
 * *   as published by the Free Software Foundation; either version 2
 * *   of the License, or (at your option) any later version.
 * *
 * *   This program is distributed in the hope that it will be useful,
 * *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 * *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * *   GNU General Public License for more details.
 * *
 * *   You should have received a copy of the GNU General Public License
 * *   along with this program; if not, you may find a copy at the FSF web
 * *   site at 'www.gnu.org' or 'www.fsf.org', or you may write to the
 * *   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * *   Boston, MA  02111-1307, USA
 ***/

package atag.apps.traffic;

import atag.runtime.DataItem;
import atag.runtime.DataPool;
import atag.runtime.NodeInfo;

public class RampSampler implements Runnable {
	
	private DataPool m_dataPool;
	private NodeInfo m_myState;

	public RampSampler(DataPool dp, NodeInfo myconfig) {
		m_dataPool = dp;
		m_myState = myconfig;
	}

	public void run() {
		try {
			for (;;) {

				handleExpiryOfTimer();
				Thread.sleep(10000);
			}
		} catch (InterruptedException e) {
			return;
		}
	}

	private void handleExpiryOfTimer() {
		
		VehiclePresence m_presence = new VehiclePresence(this.m_myState.getMyId());
		m_presence.setPresence(true);
		DataItem m_dataitem = new DataItem(IDConstants.D_VPRESENCE,
				IDConstants.T_RAMPSAMPLER, m_presence);
		m_myState.debugPrint("VehiclePresence data item generated");
		m_dataPool.putData(m_dataitem);
	}
}
